<!--TODO: Make sure you can't proceed to checkout with no orders in the Order Summarry-->
<!doctype html>

<html lang="en">

    <head>

      <meta charset="utf-8">

      <title>Elliphino's Menu</title>
        <!--Link for jquery functions-->
      <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">

      <script src="http://code.jquery.com/jquery-1.9.1.js"></script>

      <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

      <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">

        <link type="text/css" rel="stylesheet" href="../stylesheet.css">

      <script>
          //accordion menu jquery function 
      $(function() {

        $( "#accordion" ).accordion({
            collapsible: true, //collapses to only show relavent data
            active: true
        });
      });
         
	  
	  $("#contactform").on('submit', function(e){

		alert("not submited");
		return false;

		});
	  
      </script>
	  <style>
          
	  	   #banner {

            position: absolute;

            top: 0px;

            left: 0px;

            right: 0px;

            width: 100%;

            height: 175%;

            z-index: -1;

        }
	  </style>

    </head>

    <body>
	<!--<img id = "banner" src = "http://3rdbillion.net/wp-content/uploads/2014/01/de75da844f2d042aef2005036d5887342.jpg" alt = "Banner Image"/>-->
    <!--An example of an accordion layout with drop-down menus-->
    <!--CSS-->
        <style>
              .sandwichPics{
                    margin-left:80%;
              }
              .l-wrapper {
/*                    margin-top: 3%;*/
                    width: 42%;
                    margin-left: 8%;
                  float: left;
              }
			#list-wrapper {
				height: 160px;
/*                width: 33%;*/
                float:left;
                clear: right;
			  }
              #r-wrapper{
/*                    margin-top: 3%;*/
                    width: 42%;
                    margin-right: 8%;
                  float: right;
              }
              .button1{
                    margin-left:20%;
              }
			  .orderSummary{
                    color:#222;
				    font-weight: 900;
				    position:absolute;
                    float: right;
				    left:75%;
/*				    top:40%;*/
			  }
            .sandwich-header {
                font-family: Diplomata; 
                font-size: 1.7em;
            }
            .pop-sandwich {
                font-size: 1.5em;
            }
        </style>
	   
		<!--Welcomes Guest or logged-in user-->
        <h1 class="title">Elliphino's Sandwich Shop</h1>
		<div>
                <form method="POST" action="">
                    <input name = "help" value ="Help" type="submit" >
                    <?php
                    if(isset($_POST['help']))
                    {
                         $_SESSION['staffHelp']=1;
                        ?>
                    
                         <script type = 'text/javascript'> 
                            alert("A staff member will be there shortly");
                        </script>
                        <?php
                    }
                    ?>
                </form>    
             <form method="POST" action="">
                    <input name = "manager" value ="Call for a Manager" type="submit" >
                    <?php
                    if(isset($_POST['manager']))
                    {
                      $_SESSION['managerHelp'] = 1;
                        ?>
                        <script type = 'text/javascript'> 
                            alert("A manager will be with you shortly");
                        </script>
                        <?php
                    }
                    ?>
                </form>    
        </div>
		<?php
            include('orderItem.php');
            ob_start(); 
			session_start();

         
               
           
             
            //welcome user if logged in as loyalty member
            if ( isset($_SESSION['email']) ) {
                $name = $_SESSION['first_name'] . " " . $_SESSION['last_name'];
                echo "<h2 class=\"subtitle\">";
                echo "Welcome $name!";
                echo "</h2>";
            }
            else {
                //welcome guest not logged in as loyalty member
                echo "<h2 class=\"subtitle\">Welcome, Guest!</h2>";
				//session_start();//if you are a guest we need to start session, if you've logged in it has already been started from the previous page
            }
        ?>
		
		<div class="l-wrapper">
		<?php
		//find out what the most popular sandwiches are for the previous day
		$username = 'root';
        $pw = 'password';
		$con = mysqli_connect ("localhost", $username, $pw, 'elliphinos');
		
		if (mysqli_connect_errno()) 
		{
             echo "Failed to connect to MySQL: " . mysqli_connect_error();
        }
		
		//set time to the central time zone
		if ( !date_default_timezone_set ( 'America/Chicago' ) )
		{
			echo "could not set time zone!";
		}
		
		$date = new DateTime();
		$dayOfMonth = date_format($date, 'd');//get the date of today
		$yesterday = $dayOfMonth;//get yesterday's date
		$yearAndMonth = date_format($date, 'Y-m');//year and month with a dash delimiter
		
		//build date string  s
		$yesterdaysDate = $yearAndMonth . '-' . $yesterday;
		
		//this if statement executes some special case stuff for when it is the first of the month and we need to roll back the date
		if ($yesterday == 0 ) 
		{
		
			$month = date_format($date, 'm');
			if ($month == 0) 
			{ //if it is january we need to flip things back to being in december
				$month = 12;
				$year = date_format($date, 'Y') - 1;
			}
			else 
			{
				$year = date_format($date, 'Y');
			}
			
			switch ($month) 
			{ //this switch statement changes the day based on how many days are in in the previous month
				case 1:
					$yesterday = 31;
					break;
				case 2:
					$yesterday = 28 ;
					break;
				case 3:
					$yesterday = 31;
					break;
				case 4:
					$yesterday = 30;
					break;
				case 5:
					$yesterday = 31;
					break;
				case 6:
					$yesterday = 30;
					break;
				case 7:
					$yesterday = 31;
					break;
				case 8:
					$yesterday = 31;
					break;
				case 9:
					$yesterday = 30;
					break;
				case 10:
					$yesterday = 31;
					break;
				case 11:
					$yesterday = 30;
					break;
				case 12:
					$yesterday = 31;
					break;
			}
			$month = date_format('m') - 1;
			$yesterdaysDate = $year . "-" . $month;
		}
		
		//start and end times for yesterday
		$yesterdayQueryTimeStart = $yesterdaysDate . " 00:00:01";
		$yesterdayQueryTimeEnd = $yesterdaysDate . " 23:59:59";
		
		$sandwichNames = array( 'Spencers Ham Sandwich', 'Turkey Sandwich', 'The Duncan', 'Shrimp Po Boy',
		'Nicos Spicy Chicken Sandwich', 'The Jonathan');
		$sandwichCounts = array(0,0,0,0,0,0);
		
		//count up the total sandwiches ordered yesterday for each sandwich type
		for ($i = 0; $i < 6; $i++)
		{
			$sql = "SELECT COUNT(*) AS total FROM orders WHERE sandwichType='$sandwichNames[$i]' AND
			(time BETWEEN '$yesterdayQueryTimeStart' AND '$yesterdayQueryTimeEnd')";
			$result = mysqli_query($con, $sql);
			$data = mysqli_fetch_assoc($result);
			$sandwichCounts[$i] = $data['total'];
		}
		
		//loop through array storing sandwich counts and find the most popular one
		//then find the second most popular one and then the third most popular one
		//output each one after finding it.
		
		?>
		
		<div id="list-wrapper">
			<h2 class="sandwich-header">Our most popular selections are: </h2>
		
		<?php
		
		for ($i = 0; $i < 3; $i++)
		{
			$indexMostPopular = 0;//index in array of the most popular sandwich
			$totalMostPopular = 0;//number of orders of most popular sandwich
			
			for ($j = 0; $j < 6; $j++)
			{
				if ($sandwichCounts[$j] > $totalMostPopular)
				{
					$totalMostPopular = $sandwichCounts[$j];
					$indexMostPopular = $j;
					//make this small so that we don't output the most popular sandwich in the 2nd and 3rd places
					$sandwichCounts[$j] = -1;
				}
			}
			$indexMostPopular++;
			$i = $i + 1;//increment i so that the numbers that print out for the user don't start at 0
			
			//THIS NEEDS TO BE NICELY FORMATTED WITH HTML AND PRETTY CSS
			//print out sandwiches based on the index of the most popular one selected
			switch($indexMostPopular) 
			{
				case 1:
					echo  "<h3 class ='pop-sandwich'>$i.) Spencer's Classic Ham Sandwich</h3>";
					break;
				
				case 2:
					echo "<h3 class ='pop-sandwich'>$i.) The Simple Turkey Sandwich</h3>";
					break;
					
				case 3:
					echo "<h3 class ='pop-sandwich'>$i.) The Duncan</h3>";
					break;
				
				case 4:
					echo "<h3 class='pop-sandwiches'>$i.) Shrimp Po' Boy</h3>";
					break;
				
				case 5:
					echo  "<h3 class='pop-sandwiches'>$i.) Nico's Spicy Chicken Sandwich</h3>";
					break;
					
				case 6:
					echo  "<h3 class='pop-sandwiches'>$i.) The Jonathan</h3>";
					break;
					
				//do we need a default? I dunno how switch statements work
				default:
					break;
			}
			
			$i = $i - 1;//change $i back so that it doesn't mess up the loop invariant
		}
		
		?>
    </div>
		
    <div id="accordion">
      <h3>Spencer's Classic Ham Sandwich
     <!--Insert an Image of the Sandwich-->
      </h3>
    <form method="POST" action=''>

      <div>
<!--display all options user can make for order -->
                <p>
                Bread 
                    <br>
                    <select name = "breadType">
                        <option value = "Wheat">Wheat Bread</option>
                        <option value = "White">White Bread</option>
                        <option value = "French Baguette">French Baguette</option>
                        <option value = "Flat">Flat Bread</option>
						<option value = "Empty">Empty</option>

                    </select>
                </p>
                <p>
                Meat
                    <br>
                    <select name = "meatType">
                        <option value = "Ham">Ham</option>
                        <option value = "Turkey">Turkey</option>
                        <option value = "Shrimp">Shrimp</option>
                        <option value = "Chicken">Chicken</option>
                        <option value = "Meatball">Meatballs</option>
                        <option value = "pastrami">Pastrami</option>
						<option value = "Empty">Empty</option>
                    </select>
                </p>
				<p>
				Cheese
                    <br>
					<select name = "cheese">
						<option value = "Mozzarella">Mozzarella</option>
						<option value = "American">American</option>
						<option value = "Pepper-Jack">Pepper-Jack</option>
						<option value = "Empty">Empty</option>
					</select>
				</p>
                <p>
                Vegetables
                    <br>
                    <!--<select multiple = "multiple" vegetables = "vegType[]">-->
                    <select name = "vegType">
						<option value = "Lettuce">Lettuce</option>
                        <option value = "Tomatoes">Tomatoes</option>
                        <option value = "Onions">Onions</option>
                        <option value = "Green Peppers">Green Peppers</option>
						<option value = "Avocado">Avocado (+$1)</option>
                        <option value = "Black Olives">Black Olives</option>
						<option value = "Empty">Empty</option>
                    </select>
                </p>
                <p>
                Condiments
                    <br>
                    <select name = "condimentType">
                        <option value = "Ranch">Ranch</option>
                        <option value = "Mayonnaise">Mayonnaise</option>
                        <option value = "Mustard">Mustard</option>
                        <option value = "Tomato Sauce">Tomato Sauce</option>
                        <option value = "Hot Sauce">Hot Sauce</option>
						<option value = "Empty">Empty</option>
                    </select>

                </p>
                <p>
                Drink
                    <br>
                    <select name = "drinkType">
                        <option value = "Empty">Empty</option>
                        <option value = "Small">Small</option>
                        <option value = "Medium">Medium</option>
                        <option value = "Large">Large</option>
                    </select>
                </p>
                <p>
                Chips
                    <br>
                        <select name = "chipType">
                            <option value = "Empty">Empty</option>
                            <option value = "Potato Chips">Potato Chips</option>
                            <option value = "Doritos">Doritos</option>
                            <option value = "Corn Chips">Corn Chips</option>
                            <option value = "BBQ Chips">BBQ Chips</option>
                            <option value = "Sour, Cream, and Onion">Sour Cream and Onion</option>
                        </select>
                    </p>
                    <p>
                    Dessert
                        <br>
                            <select name = "Dessert">
                                <option value = "Empty">Empty</option>
                                <option value = "Cookie">Cookie</option>
                                <option value = "Brownie">Brownie</option>
                                <option value = "Vanilla Ice Cream">Vanilla Ice Cream</option>
                            </select>
                        </p>
<!--             -->

	<!--Submit button for order form-->
    <input type="submit" name="button1"  value="Submit Order">
	<!--if button is pushed then get values of form items that user selected-->
    <?php
        //if submit button is pushed then create new object SpencersHam and store selected values in it
        if(isset($_POST["button1"]))
        {
			//constructor stores all values 
			$SpencersHam = new orderItem("Spencer's Ham Sandwich", $_POST["breadType"], $_POST["meatType"], $_POST["cheese"], $_POST["vegType"],
			$_POST["condimentType"], $_POST["drinkType"], $_POST["chipType"], $_POST["Dessert"]);
			echo "Total: " . "$" . $SpencersHam->orderTotal(); //echos total for spencers ham sandwich once submitted
			if(isset( $_SESSION['orders']) )
			{
				array_push($_SESSION['orders'], $SpencersHam); //push spencers ham order onto orders array (put in order summary)
			}
			else
			{
				$_SESSION['orders'] = array($SpencersHam);
				//if nothing else in the array, put spencer ham in first index
			}
			
        }
	
		
    ?>
        </form>
      </div>
        <!--Display all items for Simple Turkey Sandwich-->
      <h3>The Simple Turkey Sandwich</h3>
        <form method="POST" action=''>
     <div>
            <!--Store items into select name tag-->
                <p>
                Bread
                <br>
                    <select name = "breadType1">
                        <option value = "White">White Bread</option>
                        <option value = "Wheat">Wheat Bread</option>
                        <option value = "French Baguette">French Baguette</option>
                        <option value = "Flat">Flat Bread</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
                <p>
                Meat
                <br>
                    <select name = "meatType1">
                        <option value = "Turkey">Turkey</option>
                        <option value = "Ham">Ham</option>
                        <option value = "Shrimp">Shrimp</option>
                        <option value = "Chicken">Chicken</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
				<p>
				Cheese
				<br>
					<select name = "cheese1">
						<option value = "Mozzarella">Mozzarella</option>
						<option value = "American">American</option>
						<option value = "Pepper-Jack">Pepper-Jack</option>
						<option value = "Empty">Empty</option>
					</select>
				</li>

					 

				</p>
                <p>
                Vegetables
                <br>
                    <select name = "vegType1">
                        <option value = "Lettuce">Lettuce</option>
                        <option value = "Tomatoes">Tomatoes</option>
                        <option value = "Onions">Onions</option>
                        <option value = "Green Peppers">Green Peppers</option>
                        <option value = "Avocado">Avocado (+$1)</option>
                        <option value = "Black Olives">Black Olives</option>
						<option value = "Empty">Empty</option>
                    </select>	
                </p>
                <p>
                Condiments
                <br>
                    <select name = "condimentType1">
                        <option value = "Mustard">Mustard</option>
                        <option value = "Mayonnaise">Mayonnaise</option>
                        <option value = "Ranch">Ranch</option>
                        <option value = "Hot Sauce">Hot Sauce</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
                <p>
                Drink
                <br>
                    <select name = "drinkType1">
                        <option value = "Empty">Empty</option>
                        <option value = "Small">Small</option>
						<option value = "Medium">Medium</option>
						<option value = "Large">Large</option>
                    </select>
                 
                </p>
                <p>
                Chips
                    <br>
                        <select name = "chipType1">
                            <option value = "Empty">Empty</option>
                            <option value = "Potato Chips">Potato Chips</option>
                            <option value = "Doritos">Doritos</option>
                            <option value = "Corn Chips">Corn Chips</option>
                            <option value = "BBQ Chips">BBQ Chips</option>
                            <option value = "Sour, Cream, and Onion">Sour Cream and Onion</option>
                        </select>
                     
                    </p>
                    <p>
                    Dessert
                        <br>
                            <select name = "Dessert1">
                                <option value = "Empty">Empty</option>
                                <option value = "Cookie">Cookie</option>
                                <option value = "Brownie">Brownie</option>
                                <option value = "Vanilla Ice Cream">Vanilla Ice Cream</option>
                            </select>
                         
                        </p>
             
	<!--if button pushed then submit form-->
    <input type="submit" name="button2"  value="Submit Order">
    <?php
        if(isset($_POST["button2"]))
        {
            //if submit button is pressed then store selected values in new object SimpleTurkey
			$SimpleTurkey = new orderItem("Turkey Sandwich", $_POST["breadType1"], $_POST["meatType1"], $_POST["cheese1"], $_POST["vegType1"],
			$_POST["condimentType1"], $_POST["drinkType1"], $_POST["chipType1"], $_POST["Dessert1"]);
            //stores values in constructor
			//if orders array already has something in it
			if(isset( $_SESSION['orders']) )
			{
                //put simple turkey order into next empty index
				array_push($_SESSION['orders'], $SimpleTurkey);
			}
			else
			{
                //else if its the first item, store it as index 1
				$_SESSION['orders'] = array($SimpleTurkey);
				
			}
			echo "Total: " . "$" . $SimpleTurkey->orderTotal(); //echo out cost of order and calls orderTotal function
        }
    ?>
         </form>
         </div>
        
        <!--Displays Items for the Duncan Order-->
      <h3>The Duncan</h3>
      <form method="POST" action=''>
      <div>
                <p>
                Bread
                <br>
                    <select name = "breadType2">
                        <option value = "Wheat">Wheat Bread</option>
                        <option value = "White">White Bread</option>
                        <option value = "French Baguette">French Baguette</option>
                        <option value = "Flat">Flat Bread</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
                <p>
                Meat
                <br>
                    <select name = "meatType2">
                        <option value = "Meatball">Meat Balls</option>
                        <option value = "Ham">Ham</option>
                        <option value = "Turkey">Turkey</option>
                        <option value = "Shrimp">Shrimp</option>
                        <option value = "Chicken">Chicken</option>
						<option value = "Empty">Empty</option>
                    </select>
                </p>
                <p>
                Vegetables
                <br>
                    <select name = "vegType2">
						<option value = "Empty">Empty</option>
                        <option value = "Lettuce">Lettuce</option>
                        <option value = "Tomatoes">Tomatoes</option>
                        <option value = "Onions">Onions</option>
                        <option value = "Green Peppers">Green Peppers</option>
                        <<option value = "Avocado">Avocado (+$1)</option>
                        <option value = "Black Olives">Black Olives</option>
                    </select>
                </p>
					<p>
				Cheese
				<br>
					<select name = "cheese2">
						<option value = "Mozzarella">Mozzarella</option>
						<option value = "American">American</option>
						<option value = "Pepper-Jack">Pepper-Jack</option>
						<option value = "Empty">Empty</option>
                    </select>
					 
				</p>
                <p>
                Condiments
                <br>
                    <select name = "condimentType2">
                        <option value = "Tomato Sauce">Tomato Sauce</option>
                        <option value = "Ranch">Ranch</option>
                        <option value = "Mayonnaise">Mayonnaise</option>
                        <option value = "Mustard">Mustard</option>
                        <option value = "Hot Sauce">Hot Sauce</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                <br>
                </p>
                <p>
                Drink
                <br>
                    <select name = "drinkType2">
                        <option value = "Empty">Empty</option>
                        <option value = "Small">Small</option>
                        <option value = "Medium">Medium</option>
                        <option value = "Large">Large</option>
                    </select>
                 
                </p>
                <p>
                Chips
                    <br>
                        <select name = "chipType2">
                            <option value = "Empty">Empty</option>
                            <option value = "Potato Chips">Potato Chips</option>
                            <option value = "Doritos">Doritos</option>
                            <option value = "Corn Chips">Corn Chips</option>
                            <option value = "BBQ Chips">BBQ Chips</option>
                            <option value = "Sour, Cream, and Onion">Sour Cream and Onion</option>
                        </select>
                     
                    </p>
                    <p>
                    Dessert
                        <br>
                            <select name = "Dessert2">
                                <option value = "Empty">Empty</option>
                                <option value = "Cookie">Cookie</option>
                                <option value = "Brownie">Brownie</option>
                                <option value = "Vanilla Ice Cream">Vanilla Ice Cream"</option>
                            </select>
                         
                        </p>
      	<!--if button pushed then submit form-->
    <input type="submit" name="button3"  value="Submit Order">
    <?php
        //if submit button is entered create an object named theDuncan and store presented values
        if(isset($_POST["button3"]))
        {
            //store values in constructor
			$theDuncan = new orderItem("The Duncan", $_POST["breadType2"], $_POST["meatType2"], $_POST["cheese2"], $_POST["vegType2"],
			$_POST["condimentType2"], $_POST["drinkType2"], $_POST["chipType2"], $_POST["Dessert2"]);
			//if array has item in an index
			if(isset( $_SESSION['orders']) )
			{
                //put order on next available index
				array_push($_SESSION['orders'], $theDuncan);
			}
			else
			{
                //if not then put it in first index
				$_SESSION['orders'] = array($theDuncan);
				
			}
			echo "Total: " . "$" . $theDuncan->orderTotal(); //echo out cost of the Duncan order and calls orderTotal function
        }
    ?>
      </div>
            </form>
        <!--Shrimp Po' Boy Order details-->
      <h3>Shrimp Po' Boy</h3>
        <form method = 'POST' action = ''>
        <div>

                <p>
                Bread
                <br>
                    <select name = "breadType">
                        <option value = "Flat">Flat Bread</option>
                        <option value = "White">White Bread</option>
                        <option value = "French Baguette">French Baguette</option>
                        <option value = "Wheat">Wheat Bread</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
                <p>
                Meat
                <br>
                    <select name = "meatType">
                        <option value = "Shrimp">Shrimp</option>
                        <option value = "Turkey">Turkey</option>
                        <option value = "Ham">Ham</option>
                        <option value = "Chicken">Chicken</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
				<p>
				Cheese
				<br>
					<select name = "cheese">
						<option value = "Mozzarella">Mozzarella</option>
						<option value = "American">American</option>
						<option value = "Pepper-Jack">Pepper-Jack</option>
						<option value = "Empty">Empty</option>
					 </select>
				</p>
                <p>
                Vegetables
                <br>
                    <select name = "vegType">
                        <option value = "Lettuce">Lettuce</option>
                        <option value = "Tomatoes">Tomatoes</option>
                        <option value = "Onions">Onions</option>
                        <option value = "Green Peppers">Green Peppers</option>
                        <option value = "Avocado">Avocado (+$1)</option>
                        <option value = "Black Olives">Black Olives</option>
						<option value = "Empty">Empty</option>
                    </select>
                  
                </p>
                <p>
                Condiments
                <br>
                    <select name = "condimentType">
                        <option value = "Mayonnaise">Mayonnaise</option>
                        <option value = "Ranch">Ranch</option>
                        <option value = "Mustard">Mustard</option>
                        <option value = "Hot Sauce">Hot Sauce</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
                <p>
                Drink
                <br>
                    <select name = "drinkType">
                        <option value = "Empty">Empty</option>
                        <option value = "Small">Small</option>
                        <option value = "Medium">Medium</option>
                        <option value = "Large">Large</option></option>
                      
                    </select>
                </p>
                <p>
                Chips
                    <br>
                        <select name = "chipType">
                            <option value = "Empty">Empty</option>
                            <option value = "Potato Chips">Potato Chips</option>
                            <option value = "Doritos">Doritos</option>
                            <option value = "Corn Chips">Corn Chips</option>
                            <option value = "BBQ Chips">BBQ Chips</option>
                            <option value = "Sour, Cream, and Onion">Sour Cream and Onion</option>
                        </select>
                    </p>
                    <p>
                    Dessert
                        <br>
                            <select name = "Dessert">
                                <option value = "Empty">Empty</option>
                                <option value = "Cookie">Cookie</option>
                                <option value = "Brownie">Brownie</option>
                                <option value = "Vanilla Ice Cream">Vanilla Ice Cream</option>
                            </select>
                         
                        </p>
             <input type="submit" name="button4"  value="Submit Order">
        <?php
        //if submit button is entered then create a new object called shrimpPoBoy and store specified values
        if(isset($_POST["button4"]))
        {
            //stores values in constructor
			$ShrimpPoBoy = new orderItem("Shrimp Po' Boy", $_POST["breadType"], $_POST["meatType"], $_POST["cheese"], $_POST["vegType"],
			$_POST["condimentType"], $_POST["drinkType"], $_POST["chipType"], $_POST["Dessert"]);
			
			//if orders array has something in it already
			if(isset( $_SESSION['orders']) )
			{
                //put shrimp po boy in next available index
				array_push($_SESSION['orders'], $ShrimpPoBoy);
				
			}
			else
			{ //if the array is empty then add it to the first index
				$_SESSION['orders'] = array($ShrimpPoBoy);
				
			}
            
			echo "Total: " . "$" . $ShrimpPoBoy->orderTotal(); //echo out cost of order and call orderTotal function
		
        }
    ?>
        
      </div>
        
      </form>


      <!--Display items for Nico's Spicy Chicken Sandwich-->

       <h3>Nico's Spicy Chicken Sandwich</h3>
      <form method = 'POST' action = ''>
      <div>
                <p>
                Bread
                <br>
                    <select name = "breadType">
                        <option value = "White">White Bread</option>
                        <option value = "Wheat">Wheat Bread</option>
                        <option value = "French Baguette">French Baguette</option>
                        <option value = "Flat">Flat Bread</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
                <p>
                Meat
                <br>
                    <select name = "meatType">
                        <option value = "Chicken">Chicken</option>
                        <option value = "Turkey">Turkey</option>
                        <option value = "Shrimp">Shrimp</option>
                        <option value = "Ham">Ham</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
				<p>
				Cheese
				<br>
					<select name = "cheese">
						<option value = "Pepper-Jack">Pepper-Jack</option>
						<option value = "American">American</option>
						<option value = "Mozzarella">Mozzarella</option>
						<option value = "Empty">Empty</option>
                    </select>
					 
				</p>
                <p>
                Vegetables
                <br>
                    <select name = "vegType">
                        <option value = "Tomatoes">Tomatoes</option>
                        <option value = "Lettuce">Lettuce</option>
                        <option value = "Onions">Onions</option>
                        <option value = "Green Peppers">Green Peppers</option>
                        <option value = "Avocado">Avocado (+$1)</option>
                        <option value = "Black Olives">Black Olives</option>
						<option value = "Empty">Empty</option>
                    </select>
                  
                </p>
                <p>
                Condiments
                <br>
                    <select name = "condimentType">
                        <option value = "Hot Sauce">Hot Sauce</option>
                        <option value = "Mayonnaise">Mayonnaise</option>
                        <option value = "Mustard">Mustard</option>
                        <option value = "Ranch">Ranch</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
                <p>
                Drink
                <br>
                    <select name = "drinkType">
                        <option value = "Empty">Empty</option>
                        <option value = "Small">Small</option>
                        <option value = "Medium">Medium</option>
                        <option value = "Large">Large</option>
                    </select>
                 
                </p>
                <p>
                Chips
                    <br>
                        <select name = "chipType">
                            <option value = "Empty">Empty</option>
                            <option value = "Potato Chips">Potato Chips</option>
                            <option value = "Doritos">Doritos</option>
                            <option value = "Corn Chips">Corn Chips</option>
                            <option value = "BBQ Chips">BBQ Chips</option>
                            <option value = "Sour, Cream, and Onion">Sour Cream and Onion</option>
                        </select>
                     
                    </p>
                    <p>
                    Dessert
                        <br>
                            <select name = "Dessert">
                                <option value = "Empty">Empty</option>
                                <option value = "Cookie">Cookie</option>
                                <option value = "Brownie">Brownie</option>
                                <option value = "Vanilla Ice Cream">Vanilla Ice Cream</option>
                            </select>
                         
                        </p>
             
        <input type="submit" name="button5"  value="Submit Order">
          
        <?php
        //if button5 is pressed then create a new object storing all items for NicosSandwich
        if(isset($_POST["button5"]))
        {
			$NicosSandwich = new orderItem("Nico's Spicy Chicken Sandwich", $_POST["breadType"], $_POST["meatType"], $_POST["cheese"], $_POST["vegType"], $_POST["condimentType"], $_POST["drinkType"], $_POST["chipType"], $_POST["Dessert"]);
			//this puts items into constructor
			
			if(isset( $_SESSION['orders']) )
			{
				array_push($_SESSION['orders'], $NicosSandwich);
				//echo "</br>" . $_SESSION['orders'][0]->bread . "</br>";
			}
			else
			{
				$_SESSION['orders'] = array($NicosSandwich);
				
			}
			echo "Total: " . "$" . $NicosSandwich->orderTotal();
        }
    ?>
        
      </div>
        
      </form>
        <!--Order details for The Jonathon-->
       <h3>The Jonathan</h3>
        <form method = 'POST' action = ''>
        <div>

                <p>
                Bread
                <br>
                    <select name = "breadType">
                        <option value = "French Baguette">French Baquette</option>
                        <option value = "White">White Bread</option>
                        <option value = "Wheat">Wheat Bread</option>
                        <option value = "Flat">Flat Bread</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
                <p>
                Meat
                <br>
                    <select name = "meatType">
                        <option value = "Turkey">Turkey</option>
                        <option value = "Ham">Ham</option>
                        <option value = "Shrimp">Shrimp</option>
                        <option value = "Chicken">Chicken</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
				<p>
				Cheese
				<br>
					<select name = "cheese">
						<option value = "American">American</option>
						<option value = "Mozzarella">Mozzarella</option>
						<option value = "Pepper-Jack">Pepper-Jack</option>
						<option value = "Empty">Empty</option>
                    </select>
					 
				</p>
                <p>
                Vegetables
                <br>
                    <select name = "vegType">
                        <option value = "Green Peppers">Green Peppers</option>
                        <option value = "Tomatoes">Tomatoes</option>
                        <option value = "Onions">Onions</option>
                        <option value = "Lettuce">Lettuce</option>
                        <<option value = "Avocado">Avocado (+$1)</option>
                        <option value = "Black Olives">Black Olives</option>
						<option value = "Empty">Empty</option>
                    </select>
                  
                </p>
                <p>
                Condiments
                <br>
                    <select name = "condimentType">
                        <option value = "Mayonnaise">Mayonnaise</option>
                        <option value = "Ranch">Ranch</option>
                        <option value = "Mustard">Mustard</option>
                        <option value = "Hot Sauce">Hot Sauce</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
                <p>
                Drink
                <br>
                    <select name = "drinkType">
                        <option value = "Empty">Empty</option>
                        <option value = "Small">Small</option>
                        <option value = "Medium">Medium</option>
                        <option value = "Large">Large</option>
                    </select>
                 
                </p>
                <p>
                Chips
                    <br>
                        <select name = "chipType">
                            <option value = "Empty">Empty</option>
                            <option value = "Potato Chips">Potato Chips</option>
                            <option value = "Doritos">Doritos</option>
                            <option value = "Corn Chips">Corn Chips</option>
                            <option value = "BBQ Chips">BBQ Chips</option>
                            <option value = "Sour, Cream, and Onion">Sour Cream and Onion</option>
                        </select>
                     
                    </p>
                    <p>
                    Dessert
                        <br>
                            <select name = "Dessert">
                                <option value = "Empty">Empty</option>
                                <option value = "Cookie">Cookie</option>
                                <option value = "Brownie">Brownie</option>
                                <option value = "Vanilla Ice Cream">Vanilla Ice Cream</option>
                            </select>
                         
                        </p>
              <input type="submit" name="button6"  value="Submit Order">
          
        <?php
        //if submit button is pushed then create new order object theJonathon and store selected values in it
        if(isset($_POST["button6"]))
        { //constructor store selected values
			$theJonathon = new orderItem("The Jonathon", $_POST["breadType"], $_POST["meatType"], $_POST["cheese"], $_POST["vegType"], $_POST["condimentType"], $_POST["drinkType"], $_POST["chipType"], $_POST["Dessert"]);
			
			//if orders array has something stored in it already then store theJonathon in next index
			if(isset( $_SESSION['orders']) )
			{
				array_push($_SESSION['orders'], $theJonathon);
			}
			else
			{    //if orders array is empty then put theJonathon in the first index
				$_SESSION['orders'] = array($theJonathon);
				
			}

			echo "Total: " . "$" . $theJonathon->orderTotal(); //echo out the cost of the sandwich and call functio orderTotal
        }
    ?>
        
      </div>
        
      </form>
        <!--Custom Sandwich allow users to make any kind of sandwich they want with no pre-sets-->
        <h3>Custom Sandwich</h3>

        <form method = 'POST' action = ''>
        <div>


             
                <p>
                Bread
                <br>
                    <select name = "breadType">
                        <option value = "Empty">Empty</option>
                        <option value = "Wheat">Wheat Bread</option>
                        <option value = "White">White Bread</option>
                        <option value = "French Baguette">French Baguette</option>
                        <option value = "Flat">Flat Bread</option>
                    </select>
                 
                </p>
                <p>
                Meat
                <br>
                    <select name = "meatType">
                        <option value = "Empty">Empty</option>
                        <option value = "Ham">Ham</option>
                        <option value = "Turkey">Turkey</option>
                        <option value = "Shrimp">Shrimp</option>
                        <option value = "Chicken">Chicken</option>
                    </select>
                 
                </p>
				<p>
				Cheese
				<br>
					<select name = "cheese">
						<option value = "Empty">Empty</option>
						<option value = "Mozzarella">Mozzarella</option>
						<option value = "American">American</option>
						<option value = "Pepper-Jack">Pepper-Jack</option>
						
					 </select>
				</p>
                <p>
                Vegetables
                <br>
                    <select name = "vegType">
                        <option value = "Empty">Empty</option>
                        <option value = "Lettuce">Lettuce</option>
                        <option value = "Tomatoes">Tomatoes</option>
                        <option value = "Onions">Onions</option>
                        <option value = "Green Peppers">Green Peppers</option>
                        <option value = "Avocado">Avocado (+$1)</option>
                        <option value = "Black Olives">Black Olives</option>
                    </select>
                  
                </p>
                <p>
                Condiments
                <br>
                    <select name = "condimentType">
                        <option value = "Empty">Empty</option>
                        <option value = "Ranch">Ranch</option>
                        <option value = "Mayonnaise">Mayonnaise</option>
                        <option value = "Mustard">Mustard</option>
                        <option value = "Hot Sauce">Hot Sauce</option>
                    </select>
                 
                </p>
                <p>
                Drink
                <br>
                    <select name = "drinkType">
                        <option value = "Empty">Empty</option>
                        <option value = "Small">Small</option>
                        <option value = "Medium">Medium</option>
                        <option value = "Large">Large</option>
                   
                    </select>
                 
                </p>
                <p>
                Chips
                    <br>
                        <select name = "chipType">
                            <option value = "Empty">Empty</option>
                            <option value = "Potato Chips">Potato Chips</option>
                            <option value = "Doritos">Doritos</option>
                            <option value = "Corn Chips">Corn Chips</option>
                            <option value = "BBQ Chips">BBQ Chips</option>
                            <option value = "Sour, Cream, and Onion">Sour Cream and Onion</option>
                        </select>
                     
                    </p>
                    <p>
                    Dessert
                        <br>
                            <select name = "Dessert">
                                <option value = "Empty">Empty</option>
                                <option value = "Cookie">Cookie</option>
                                <option value = "Brownie">Brownie</option>
                                <option value = "Vanilla Ice Cream">Vanilla Ice Cream</option>
                            </select>
                         
                        </p>
             
        <input type="submit" name="button7"  value="Submit Order">
          
        <?php
        //if submit button is pushed then create new order item named Custom
        if(isset($_POST["button7"]))
        {
            //constructor stores selected values
			$Custom = new orderItem("Custom Sandwich", $_POST["breadType"], $_POST["meatType"], $_POST["cheese"],                                                 $_POST["vegType"], $_POST["condimentType"], $_POST["drinkType"], $_POST["chipType"], $_POST["Dessert"]);
			
			if(isset( $_SESSION['orders']) )
			{
                //if array already stores values then store Custom order in next empty index
				array_push($_SESSION['orders'], $Custom);
			}
			else
			{
                //if the orders array is empty then put Custom order in first index
				$_SESSION['orders'] = array($Custom);
				
			}

			echo "Total: " . "$" . $Custom->orderTotal(); //print out cost of Custom sandwich and calls orderTotal function
        }
    ?>
        
      </div>
        <!--Random Sandwich gives users a random sandwich when they do not know what they want-->
      </form>
      <h3>Random Sandwich</h3>
      <form method = "POST" action = "">
	  <div> 
	  
	  <?php
        //switch statement to choose ingredients completely at random
		//Choose random bread
		switch(rand(1,4)){
		case 1:
			$rand_bread = "White";
		break;
		case 2:
			$rand_bread = "Wheat";
		break;
		case 3:
			$rand_bread = "French Baguette";
		break;
		case 4:
			$rand_bread = "Flat";
		break;
		default:
			$rand_bread = "Empty";
		break;
		}
		//Choose random meat
		switch(rand(1,6)){
		case 1:
			$rand_meat = "Ham";
		break;
		case 2:
			$rand_meat = "Turkey";
		break;
		case 3:
			$rand_meat = "Shrimp";
		break;
		case 4:
			$rand_meat = "Chicken";
		break;
		case 5:
			$rand_meat = "Meatball";
		break;
		case 6:
			$rand_meat = "Pastrami";
		break;
		default:
			$rand_meat = "Empty";
		break;
		}
		//Choose random cheese
		switch(rand(1,3)){
		case 1:
			$rand_cheese = "American";
		break;
		case 2:
			$rand_cheese = "Pepper-Jack";
		break;
		case 3:
			$rand_cheese = "Mozzarella";
		break;
		default:
			$rand_cheese = "Empty";
		break;
		}
		//Choose random veggie
		switch(rand(1,6)){
		case 1:
			$rand_veggies = "Lettuce";
		break;
		case 2:
			$rand_veggies = "Tomatoes";
		break;
		case 3:
			$rand_veggies = "Onions";
		break;
		case 4:
			$rand_veggies = "Green Peppers";
		break;
		case 5:
			$rand_veggies = "Black Olives";
		break;
		case 6:
			$rand_veggies = "Avocado";
		break;
		default:
			$rand_veggies = "Empty";
		break;
		}
		//Choose random sauce
		switch(rand(1,5)){
		case 1:
			$rand_sauce = "Ranch";
		break;
		case 2:
			$rand_sauce = "Mayonnaise";
		break;
		case 3:
			$rand_sauce = "Mustard";
		break;
		case 4:
			$rand_sauce = "Tomato Sauce";
		break;
		case 5:
			$rand_sauce = "Hot Sauce";
		break;
		default:
			$rand_sauce = "Empty";
		break;
		}
        //displays whats on random sandwich
		echo "<h3>" . "Your random sandwich is:" . "</h3>" . "</br>";
		echo "Bread: " . $rand_bread . "</br>";
        echo "Meat: " . $rand_meat . "</br>";
        echo "Cheese: " . $rand_cheese . "</br>";
        echo "Vegetables: " . $rand_veggies . "</br>";
        echo "Condiments: " . $rand_sauce . "</br>";
		?>
		<p>
            <!--Lets them pick a drink, chips, and dessert-->
                Drink
                    <br>
                    <select name = "drinkType">
                        <option value = "Empty">Empty</option>
                        <option value = "Small">Small</option>
                        <option value = "Medium">Medium</option>
                        <option value = "Large">Large</option>
                    </select>
                </p>
                <p>
                Chips
                    <br>
                        <select name = "chipType">
                            <option value = "Empty">Empty</option>
                            <option value = "Potato Chips">Potato Chips</option>
                            <option value = "Doritos">Doritos</option>
                            <option value = "Corn Chips">Corn Chips</option>
                            <option value = "BBQ Chips">BBQ Chips</option>
                            <option value = "Sour, Cream, and Onion">Sour, Cream, and Onion</option>
                        </select>
                    </p>
                    <p>
                    Dessert
                        <br>
                            <select name = "Dessert">
                                <option value = "Empty">Empty</option>
                                <option value = "Cookie">Cookie</option>
                                <option value = "Brownie">Brownie</option>
                                <option value = "Vanilla Ice Cream">Vanilla Ice Cream</option>
                            </select>
                        </p>
		<input type="submit" name="button8"  value="Submit Order">
		<h4>(15% off)</h4>
		<?php
if (isset($_POST["button8"]))
{
    //if submit button is pushed then store selected values into constructor for object
  $Random = new orderItem("Random Sandwich", $rand_bread, $rand_meat, $rand_cheese, $rand_veggies, $rand_sauce, $_POST["drinkType"], $_POST["chipType"], $_POST["Dessert"]);
		if (isset($_SESSION['orders']))
			{
			array_push($_SESSION['orders'], $Random);
			}
		else
			{
			$_SESSION['orders'] = array($Random);
			}	
  echo"Total: "."$".$Random->orderTotal();
}
?>
	  </div>
	  </form>
	  
      <h3>Sandwich of the Day</h3>
      <form method = "POST" action = "">
	  <div> 
	  
	  <?php
        //switch sandwich to decide what day of the week it is
        //the day of the week will determine the sandwich of the day
		//Find the day
		$day = date("l");
		switch($day){
		case "Monday":
			$otd_name = "Spencer's Classic Ham Sandwich";
			$otd_bread = "Wheat";
			$otd_meat = "Ham";
			$otd_cheese = "Mozzarella";
			$otd_veggies = "Lettuce";
			$otd_sauce = "Ranch";
		break;
		case "Tuesday":
			$otd_name = "The Simple Turkey Sandwich";
			$otd_bread = "White";
			$otd_meat = "Turkey";
			$otd_cheese = "Mozzarella";
			$otd_veggies = "Lettuce";
			$otd_sauce = "Mustard";
		break;
		case "Wednesday":
			$otd_name = "The Duncan";
			$otd_bread = "Wheat";
			$otd_meat = "Meatball";
			$otd_cheese = "Mozzarella";
			$otd_veggies = "Empty";
			$otd_sauce = "Tomato Sauce";
		break;
		case "Thursday":
			$otd_name = "Shrimp Po' Boy";
			$otd_bread = "Flat";
			$otd_meat = "Shrimp";
			$otd_cheese = "Mozzarella";
			$otd_veggies = "Lettuce";
			$otd_sauce = "Mayonnaise";
		break;
		case "Friday":
			$otd_name = "Nico's Spicy Chicken Sandwich";
			$otd_bread = "White";
			$otd_meat = "Chicken";
			$otd_cheese = "Pepper-Jack";
			$otd_veggies = "Tomatoes";
			$otd_sauce = "Hot Sauce";
		break;
		case "Saturday":
			$otd_name = "The Jonathan";
			$otd_bread = "French Baguette";
			$otd_meat = "Turkey";
			$otd_cheese = "American";
			$otd_veggies = "Green Peppers";
			$otd_sauce = "Mayonnaise";
		break;
		case "Sunday":
			$otd_name = "Sunday's Special";
			$otd_bread = "Wheat";
			$otd_meat = "Turkey";
			$otd_cheese = "Pepper-Jack";
			$otd_veggies = "Green Peppers";
			$otd_sauce = "Hot Sauce";
		break;
		}
        //echos out the result of switch statement based on the current day
		echo "<h3>" . "The Sandwich of the Day for " . $day . " is: " . $otd_name . "</h3>" . "</br>";
		echo "Bread: " . $otd_bread . "</br>";
        echo "Meat: " . $otd_meat . "</br>";
        echo "Cheese: " . $otd_cheese . "</br>";
        echo "Vegetables: " . $otd_veggies . "</br>";
        echo "Condiments: " . $otd_sauce . "</br>";
		?>
		<p>
                Drink
                    <br>
                    <select name = "drinkType">
                        <option value = "Empty">Empty</option>
                        <option value = "Small">Small</option>
                        <option value = "Medium">Medium</option>
                        <option value = "Large">Large</option>
                    </select>
                </p>
                <p>
                Chips
                    <br>
                        <select name = "chipType">
                            <option value = "Empty">Empty</option>
                            <option value = "Potato Chips">Potato Chips</option>
                            <option value = "Doritos">Doritos</option>
                            <option value = "Corn Chips">Corn Chips</option>
                            <option value = "BBQ Chips">BBQ Chips</option>
                            <option value = "Sour, Cream, and Onion">Sour, Cream, and Onion</option>
                        </select>
                    </p>
                    <p>
                    Dessert
                        <br>
                            <select name = "Dessert">
                                <option value = "Empty">Empty</option>
                                <option value = "Cookie">Cookie</option>
                                <option value = "Brownie">Brownie</option>
                                <option value = "Vanilla Ice Cream">Vanilla Ice Cream</option>
                            </select>
                        </p>
		<input type="submit" name="button9"  value="Submit Order">
		<h4>(15% off)</h4>
		<?php
if (isset($_POST["button9"]))//if they submit the order
{ //pass selected values into constructor for onject OfTheDay
	$OfTheDay = new orderItem("Sandwich of the Day", $otd_bread, $otd_meat, $otd_cheese, $otd_veggies, $otd_sauce,
		$_POST["drinkType"], $_POST["chipType"], $_POST["Dessert"]);
		if (isset($_SESSION['orders']))
			{
			array_push($_SESSION['orders'], $OfTheDay);
			}
		else
			{
			$_SESSION['orders'] = array($OfTheDay);
			}	
		echo"Total: "."$".$OfTheDay->orderTotal();
}
?>
	  </div>
	  </form>
	  <!--Get Lucky and win an order item for free-->
	<h3>Kid's Meal</h3> 

        <form method = 'POST' action = ''>
        <div>


             
                <p>
                Bread
                <br>
                    <select name = "breadType">
                        <option value = "Wheat">Wheat Bread</option>
                        <option value = "White">White Bread</option>
                        <option value = "Empty">Empty</option>
                    </select>
                </p>
                Meat
                <p>
                    <select name = "meatType">
                        <option value = "Turkey">Turkey</option>
                        <option value = "Ham">Ham</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
				<p>
				Cheese
				<br>
					<select name = "cheese">
						<option value = "Mozzarella">Mozzarella</option>
						<option value = "American">American</option>
						<option value = "Empty">Empty</option>
					 </select>
				</p>
                <p>
                Vegetables
                <br>
                    <select name = "vegType">
                        <option value = "Lettuce">Lettuce</option>
                        <option value = "Tomatoes">Tomatoes</option>
                        <option value = "Avocado">Avocado (+$1)</option>
						<option value = "Empty">Empty</option>
                    </select>
                  
                </p>
                <p>
                Condiments
                <br>
                    <select name = "condimentType">
                        <option value = "Mayonnaise">Mayonnaise</option>
                        <option value = "Ranch">Ranch</option>
                        <option value = "Mustard">Mustard</option>
						<option value = "Empty">Empty</option>
                    </select>
                 
                </p>
                <p>
                Drink
                <br>
                    <select name = "drinkType">
                        <option value = "Empty">Empty</option>
                        <option value = "Small">Small</option>
                    </select>
                </p>
                <p>
                Chips
                    <br>
                        <select name = "chipType">
                            <option value = "Empty">Empty</option>
                            <option value = "Potato Chips">Potato Chips</option>
                            <option value = "Doritos">Doritos</option>
                            <option value = "Corn Chips">Corn Chips</option>
                            <option value = "BBQ Chips">BBQ Chips</option>
                            <option value = "Sour, Cream, and Onion">Sour Cream and Onion</option>
                        </select>
                    </p>
                    <p>
                    Dessert
                        <br>
                            <select name = "Dessert">
                                <option value = "Empty">Empty</option>
                                <option value = "Cookie">Cookie</option>
                                <option value = "Brownie">Brownie</option>
                                <option value = "Vanilla Ice Cream">Vanilla Ice Cream</option>
                            </select>
                         
                        </p>
                    </select>
                </p>
        
        <input type="submit" name="button10"  value="Submit Order">
        <?php
        if (isset($_POST["button10"]))//if they submit the order
        { //pass selected values into constructor for onject OfTheDay
            if(  $_SESSION['numEntrees'] < $_SESSION['numKids'] &&   $_SESSION['numEntrees']>0 )
            {
            
                $freeKidsMeal = new orderItem("Free Kid's Meal", $_POST['breadType'], $_POST['meatType'], $_POST['cheese'], $_POST['vegType'],$_POST['condimentType'], $_POST['drinkType'], $_POST['chipType'], $_POST['Dessert']);
                if (isset($_SESSION['orders']))
			     {
			         array_push($_SESSION['orders'], $freeKidsMeal);
			     }
		          else
			     {
			         $_SESSION['orders'] = array($freeKidsMeal);
			     }	
		          echo"Total: "."$".$freeKidsMeal->orderTotal();
                
            
                $_SESSION['numEntrees']--;
            }
            
            else if( $_SESSION['numKids'] <= $_SESSION['numEntrees'] && $_SESSION['numKids']>0)
            {
                $freeKidsMeal = new orderItem("Free Kid's Meal", $_POST['breadType'], $_POST['meatType'], $_POST['cheese'], $_POST['vegType'],$_POST['condimentType'], $_POST['drinkType'], $_POST['chipType'], $_POST['Dessert']);
                if (isset($_SESSION['orders']))
			     {
			          array_push($_SESSION['orders'], $freeKidsMeal);
			     }
		          else
			     {
			             $_SESSION['orders'] = array($freeKidsMeal);
			     }	
		          echo"Total: "."$".$freeKidsMeal->orderTotal();
                
            
                $_SESSION['numKids']--;
            }
            else
            {
	          $kidsMeal = new orderItem("Kid's Meal", $_POST['breadType'], $_POST['meatType'], $_POST['cheese'], $_POST['vegType'],
              $_POST['condimentType'], $_POST['drinkType'], $_POST['chipType'], $_POST['Dessert']);
		      if (isset($_SESSION['orders']))
			  {
			     array_push($_SESSION['orders'], $kidsMeal);
			  }
		      else
			  {
			     $_SESSION['orders'] = array($kidsMeal);
			  }	
		      echo"Total: "."$".$kidsMeal->orderTotal();
            }
        }
        ?>
        </div>
        </form>
    
    </div>
    </form>
                 
<?php
//----------------------------Sandwich Roullette-----------------------------

	
if(isset($_SESSION['email']) && $_SESSION['flag'] == 0){
        $prize = rand(1,100); 

		if($prize % 50 == 0){
			$prize = "CONGRATULATIONS!! You've won a Vanilla Ice Cream !";
			$FREE = new orderItem("Free Prize", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Vanilla Ice Cream");
			$win = TRUE;
		}
		else if($prize % 25 == 0){
			$prize = "CONGRATULATIONS!! You've won a Brownie!";
			$win = TRUE;
			$FREE = new orderItem("Free Prize", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Brownie");
		}
		else if($prize % 20 == 0){
			$prize = "CONGRATULATIONS!! You've won a Large Drink!";
			$win = TRUE;
			$FREE = new orderItem("Free Prize", "Empty", "Empty", "Empty", "Empty", "Empty", "Large", "Empty", "Empty");
		}
		else if($prize % 10 == 0){
			$prize = "CONGRATULATIONS!! You've won a Cookie!";
			$win = TRUE;
			$FREE = new orderItem("Free Prize", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Cookie");
		}
		else if($prize % 5 == 0){
			$prize = "CONGRATULATIONS!! You've won a Medium Drink!";
			$win = TRUE;
			$FREE = new orderItem("Free Prize", "Empty", "Empty", "Empty", "Empty", "Empty", "Medium", "Empty", "Empty");
		}
		else if($prize % 4 == 0){
			$prize = "CONGRATULATIONS!! You've won a bag of Chips!";
			$win = TRUE;
			$FREE = new orderItem("Free Prize", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Potato Chips", "Empty");
		}
		else if($prize % 2 == 0){
			$prize = "CONGRATULATIONS!! You've won a Small Drink!";
			$win = TRUE;
			$FREE = new orderItem("Free Prize", "Empty", "Empty", "Empty", "Empty", "Empty", "Small", "Empty", "Empty");
		}
		else{
			$prize = "We're sorry, you didn't win this time. Try again on your next visit";
			$win = FALSE;
		}
        ?>
          <script type = 'text/javascript'>
            //<!--
            $(window).load(function() {
                 var prize = "<?php echo $prize;?>";
                alert(prize);
            });
            //-->
          </script>
        <?php
		//if (isset($_POST["button10"]))
		//{
		//echo "<h4>" . $prize . "</h4>" . "</br>";
		if($win){
			if (isset($_SESSION['orders']))
				{
				array_push($_SESSION['orders'], $FREE);
				}
			else
				{
				$_SESSION['orders'] = array($FREE);
				}	
		}
        $_SESSION['flag'] = 1;
      }
		?>
<!--needs CSS! Andrew or Jonathon-->
    </div>
<div id="r-wrapper">
    <?php
                if(isset($_SESSION['promptForKids']) && isset($_SESSION['enterFieldOnce']))
            {
                if($_SESSION['promptForKids']==0 && $_SESSION['enterFieldOnce'] == 0)
                {
                   ?>
                  <form method="post" action="">
                  <h4>How many kids do you have?</h4> <input type="text" name = "numKids" value="" maxlength = 1><br>
                  <input type = "submit" name = "submit5" value = "Submit"></form>
                    <?php
             
                    $_SESSION['promptForKids']=1;
                }
                
            }
            if(isset($_POST['submit5']))
            {
                if(isset($_POST['numKids']))
                {
                    $_SESSION['numKids'] = $_POST['numKids'];
                    echo "<h2>With the purchase of " .  $_SESSION['numKids'] . " entrees, you can get " .  $_SESSION['numKids'] . "                         free kids meals!!!</h2>";
                  
                    $_SESSION['enterFieldOnce'] = 1;
                }
            }
?>
    <div id="sum-header">
        <h2 id = "summaryHeader">Order Summary</h2>
    </div>
    <div id="orderSummary">
    
 <!--Summarizes order that user has selected-->
<!--List Items, prices, and total-->
	<?php
    //create function for order summary. Is called after delete button is pushed. Will print new array with new TOTAL
    function orderSummary()
    {
        $i=0; //counter for order summary
        $counter=1;
        
        //$j=0;
        $_SESSION['orderTotal'] = 0; //set TOTAl = 0, if item is deleted from array foreach will not add its cost to orderTotal 
        if(isset($_SESSION['orders']))
            {
              foreach($_SESSION['orders'] as $anOrder)
              {
                  $_SESSION['orderTotal'] += $anOrder->total;

                  //$i++;
                 echo "<h3 class=\"lineHeader\">" . $counter . ". " .  $anOrder->sandwichType . "</h3>";
                echo "<p class=\"lineOrder\">";
                 echo "<strong>Bread: </strong>" . $anOrder->bread . "</br>" . "<strong>Meat: </strong>" . $anOrder->meat  . "</br> " . "<strong>Cheese: </strong>" . $anOrder->cheese;
                 echo  "</br>" .  "<strong>Veggies: </strong>" . $anOrder->veggies . "</br>" . "<strong>Condiments: </strong>" . $anOrder->condiments;
                 echo  "</br>" . "<strong>Drink Size: </strong>" . $anOrder->drink . "</br>" . "<strong>Chips: </strong>" . $anOrder->chips;
                 echo  "</br>" . "<strong>Dessert: </strong>" .  $anOrder->dessert;
                 echo "</p>";
                 	
               // echo "Cost: $" . $anOrder->total."</br>";
				if($anOrder->bread!="Empty"&&$anOrder->drink!="Empty")
                        {
                                echo "<p class=\"lineOrder\"><strong>Enjoy our entree/drink $1 discount!</strong></p>";
                            
                        }
                if($anOrder->bread!="Empty"&&$anOrder->meat!="Empty")
                {
                    $_SESSION['numEntrees']++;
                
                }
				 $cost = sprintf ("%.2f", $anOrder->total);
                 echo "<h4 class=\"lineCost\">" . "</br>" ."Cost: " . "$" . $cost . "</h4>";
                 $counter++;

            ?>
                <form method="POST" action=''>
                    <!--must use $i to get correct delete button-->
                <input type="submit" name="<?php echo $i; ?>"  value="Delete">
                
            <?php
                  $i++;
                  
              }

            }
            //prints out TOTAL of all orders
		  $final_total = sprintf ("%.2f", $_SESSION['orderTotal']);
          echo "<h2 style = \"color:#66FF00\">" . "TOTAL: " . "$" . $final_total . "</h2>";      
        }
        ?>
               
        <?php
        if(isset($_SESSION['orders'])){
            for($j = 0; $j < sizeof($_SESSION['orders']); $j++)//loops counter $j through sizeof orders array
            {
                if(isset($_POST["$j"])) //if delete button was pushed on $j item then do the following:
                {
                    //subtract value of item being deleted from total
                    $_SESSION['orderTotal'] = $_SESSION['orderTotal'] - $_SESSION['orders'][$j]->total;
                    if($_SESSION['orders'][$j]->bread!="Empty" && $_SESSION['orders'][$j]!="Empty")
                    {
                          $_SESSION['numEntrees']--;
                    }
                    //delete current index in array
                    unset($_SESSION['orders'][$j]);
                    //re index array after deletion
                    $_SESSION['orders'] = array_values($_SESSION['orders']);

                }


            }
        }
        ?>

        <form method = "POST" action = ''>
            <input type = "submit" name = "checkout" value="Proceed to Checkout">
            <?php
                if(isset($_POST['checkout']))
                {
                    if($_SESSION['orderTotal'] > 0)
                    {
                        $flag = NULL;
                        header("Location: checkOut.php"); //if greater than 0, redirect to checkOut page
                    }
                    else
                        echo "Your total must be greater than $0."; //if = to 0 then do no redirect
                }
            ?>
        </form>
        <?php
            orderSummary();  
            ob_flush(); 
        ?>
                    </form>
        </div>
    </div>  
		
		<a href="eng_login.php" id="back">Back</a>

    </body>

</html>

